import { defHttp } from '/@/utils/http/axios';
import setting from '/@/settings/projectSetting';

const Api = {
  registerFile: `${setting.interfacePrefix}/upload/register`, //上传文件
  uploadChunk: `${setting.interfacePrefix}/upload/uploadChunk`, //上传文件
  mergeFile: `${setting.interfacePrefix}/upload/merge`, //合并断点续的文件
  delete: `${setting.interfacePrefix}/upload/delete`, //删除上传文件的信息
};

export const registerFile = (params?: any) =>
  defHttp.post<any>({
    url: Api.registerFile,
    params,
  });

export const uploadChunk = (params?: any) =>
  defHttp.post<any>(
    {
      url: Api.uploadChunk,
      params,
      headers: {
        'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryVD0qp8RY7NId5ucK',
      },
    },
    {
      isTransformResponse: false,
    },
  );

export const mergeFile = (params?: any) =>
  defHttp.post<any>({
    url: Api.mergeFile,
    params,
  });

export const delFile = (params?: any) =>
  defHttp.post<any>({
    url: Api.delete,
    params,
  });
